
import math

r = math.sqrt(math.pow(11-3, 2) + math.pow(13-5, 2))
theta = math.atan2(13-5, 11-3)/math.pi * 180

print(r, theta)

import numpy as np
import cv2
x = np.array([[0, 1, 2], [0, 1, 2], [0, 1, 2]], np.float64) -1 
y = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 2]], np.float64) - 1

r, theta = cv2.cartToPolar(x, y, angleInDegrees=True)
print("r = ", r)
print("theta = ", theta)

angle = np.array([[30, 31], [30, 31]], np.float32)
r = np.array([[10, 10], [11, 11]], np.float32)
x, y = cv2.polarToCart(r, angle, angleInDegrees=True)
print("===========")
print("x = ", x)
print("y = ", y)